package com.qf.j2112.controller;

import com.qf.j2112.anno.JWTAnno;
import com.qf.j2112.po.SysRole;
import com.qf.j2112.po.SysUser;
import com.qf.j2112.service.SysRoleService;
import com.qf.j2112.vo.ActionResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api")
@CrossOrigin
public class SysRoleController {

    @Resource
    private SysRoleService sysRoleService;

    /*
    //以下后台增删查改
    */
    //获取全部角色列表
    @JWTAnno(name = "获取全部角色列表")
    @GetMapping("/roles")
    public ActionResultVO getRoleist(){
        ActionResultVO vo=null;
        List<SysRole> roles = sysRoleService.findAll();
        if (!ObjectUtils.isEmpty(roles)){
            vo=new ActionResultVO(200,"查询全部用户成功",roles);
        }else {
            vo=new ActionResultVO(-200,"查询全部用户失败",null);
        }
        return vo;
    }

}
